home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_c / lzw4w10.zip / DIR_IO.C < prev    next >
Text File  |  1994-01-30  |  1KB  |  71 lines

  1. /*
  2. **  DIR_IO.C
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <dos.h>
  8. #include <string.h>
  9. #include "windows.h"
  10. #include "dir_io.h"
  11.  
  12. /*** define compiler specfic includes ***/
  13.  
  14. #ifdef __BORLANDC__
  15. /* Borland Turbo C compiler */
  16. #include <dir.h>
  17. static char DTAbuffer[256];
  18. static struct ffblk DirStruct;
  19. #endif
  20.  
  21. #ifdef _MSC_VER
  22. /* Microsoft C compiler */
  23. static struct _find_t DirStruct;
  24. #endif
  25.  
  26. /*** FindFirst() and FindNext() functions ***/
  27.  
  28. int FindFirst(char *FileSpec,char *Buffer)
  29. {
  30. #ifdef _MSC_VER
  31.  if(_dos_findfirst(FileSpec,_A_NORMAL,&DirStruct)==0)
  32.    {
  33.     strncpy(Buffer,DirStruct.name,13);
  34.     return(TRUE);
  35.    }
  36.  return(FALSE);
  37. #endif
  38.  
  39. #ifdef __BORLANDC__
  40.  setdta(DTAbuffer);
  41.  if( findfirst(FileSpec,&DirStruct,0)==0)
  42.    {
  43.     strncpy(Buffer,DirStruct.ff_name,13);
  44.     return(TRUE);
  45.    }
  46.  return(FALSE);
  47. #endif
  48. }
  49.  
  50. int FindNext(char *Buffer)
  51. {
  52. #ifdef _MSC_VER
  53.  int Result;
  54. Result = _dos_findnext(&DirStruct);
  55. if(Result==0)
  56.    {
  57.     strncpy(Buffer,DirStruct.name,13);
  58.     return(TRUE);
  59.    }
  60.  return(FALSE);
  61. #endif
  62.  
  63. #ifdef __BORLANDC__
  64.  if( findnext(&DirStruct)==0 )
  65.    {
  66.     strncpy(Buffer,DirStruct.ff_name,13);
  67.     return(TRUE);
  68.    }
  69.  return(FALSE);
  70. #endif
  71. }